home *** CD-ROM | disk | FTP | other *** search
-
- function PDAnswer (number)
- {
- this.master=number;
- this.flo=formatAnswerForLocale(formatAnswerForDisplay(number, 1));
- this.sci=formatAnswerForLocale(formatAnswerForDisplay(number, 2));
- this.eng=formatAnswerForLocale(formatAnswerForDisplay(number, 3));
- this.bin=(Math.floor(number)).toString(2);
- this.oct=(Math.floor(number)).toString(8);
- this.hex=(Math.floor(number)).toString(16);
- var self = this;
- this.getAnswer=function(type)
- {
- switch(type) {
- case 1:
- if (preferencesPrecision) {
- return formatAnswerForLocale(formatAnswerForDisplay(formatWithGlobalPrecision(this.master)));
- } else
- return this.flo;
- break;
- case 2:
- if (preferencesPrecision) {
- return formatAnswerForLocale(formatAnswerForDisplay(formatWithGlobalPrecision(this.master)));
- } else
- return this.sci;
- break;
- case 3:
- if (preferencesPrecision) {
- return formatAnswerForLocale(formatAnswerForDisplay(formatWithGlobalPrecision(this.master)));
- } else
- return this.eng;
- break;
- case 4:
- return formatAnswerForLocale(formatPercentNumber(formatAnswerForDisplay(formatWithGlobalPrecision(100*this.master), 1)));
- break;
- case 5:
- return formatBinaryNumber(this.bin);
- break;
- case 6:
- return formatOctNumber(this.oct);
- break;
- case 7:
- return formatHexNumber(this.hex);
- break;
- }
- return 'error';
- }
- this.reformatNumbers=function()
- {
- this.flo=formatAnswerForLocale(formatAnswerForDisplay(this.master, 1));
- }
- }
- function PDNumber()
- {
- this.masterNumber=false;
- this.superMasterNumber=false;
- this.number=false;
- var self=this;
- if (arguments.length) {
- this.masterNumber=arguments[0];
- this.number=parseFloat(arguments[0]);
- if (isNaN(this.number))
- this.number=false;
- }
- this.getNumber=function()
- {
- return this.number;
- }
- this.getMasterNumber=function()
- {
- return this.masterNumber;
- }
- this.setMasterNumber=function(newNumber)
- {
- self.masterNumber=parseFloat(newNumber);
- }
- this.initWithNumber=function(numberToInitWith)
- {
- this.number=numberToInitWith;
- }
- }
-